import java.util.*;

public class Test1 {
    public static void main(String[] args) {
        Deque<String> deque = new LinkedList<>();
        deque.offerFirst("头插1");
        deque.offerFirst("头插2");
        deque.offerLast("尾插2");
        deque.offerLast("尾插1");

        while(!deque.isEmpty()){
            System.out.println(deque.pollFirst());
            System.out.println(deque.pollLast());
        }
    }

    public static void main2(String[] args) {
        Queue<String> queue = new LinkedList<>();
        queue.offer("1");
        queue.offer("12");
        queue.offer("123");
        queue.offer("1234");
        queue.offer("12345");

        int size= queue.size();
        for (int i = 0; i < size; i++) {
            System.out.println(queue.poll());
        }
    }

//    public static void main1(String[] args) {
//        Stack<Integer> stack = new Stack<>();
//        stack.push(1);
//        stack.push(2);
//        stack.push(3);
//        stack.push(4);
//        stack.push(5);
//        int size=stack.size();
//        for (int i = 0; i < size; i++) {
//            System.out.println(stack.pop());
//        }
//    }
}
